package com.itheima.dao;

import java.sql.SQLException;
import java.util.List;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import com.itheima.bean.Product;
import com.itheima.utils.DataSourceUtils;

public class ProductDao {

	public List<Product> findAllProducts() throws SQLException {
		//创建QueryRunner对象
		QueryRunner qr = new QueryRunner(DataSourceUtils.getDataSource());
		//编写sql
		String sql = "select * from product";
		//执行sql
		List<Product> list = qr.query(sql, new BeanListHandler<Product>(Product.class));
		return list;
	}

}
